Skip to content

feat(bot): reply keyboard in DMs with Play, Today's result and Menu - #96

Merged
amtiYo merged 2 commits into
devfrom
feat/dm-reply-keyboard
Nov 16, 2026
Merged

amtiYo merged 2 commits into
devfrom
feat/dm-reply-keyboard

Conversation

@amtiYo

@amtiYo amtiYo commented Nov 16, 2026

Copy link
Copy Markdown
Member

Closes #95.

In a DM the menu button opens the Mini App, so the command list is hidden and a new player has nothing to press after the first game. This adds a persistent reply keyboard in DMs:

[ Play ]                      web_app to /today, primary style
[ Today's result ] [ Menu ]   text
  • Play opens the day in the Mini App (without APP_URL it is a text button that sends the menu).
  • Today's result, read in the DM's zone:
    • no round today: says so;
    • before 20:00: whether the person has answered and how long until the result; if an earlier reveal in one of their groups already closed the day, says answers are closed;
    • from 20:00: score (3 500 for 312 km) and world rank, phrased "so far" until the last zone's reveal, plus an Open the result button into the Mini App; without an answer, "No answer from you today."
      The rank is the same nameless one the Mini App shows after answering.
  • Menu sends the existing home panel.

How it is sent: a message has one reply_markup and the panel's is inline, so the keyboard rides on its own short line ("The buttons below stay with you…"). It goes out on /start in a DM, before the panel, and again when the person's language changes (picked or Follow Telegram). Groups never get it: sendKeyboard refuses any non-private chat, and labels typed in a group are ignored.

Button texts are matched in all 16 languages (a keyboard drawn before a language change still works) before any other text handling, and count as nothing else. No request_location (a DM location is the day's answer) and no other request buttons.

internal/telegram gains Keyboard (is_persistent, resize_keyboard, input_field_placeholder) and SendKeyboard; no tg release. The bot.Store interface gains GuessOf and World, both existing db.Store methods. New strings: kb.*, today.*, unit.hm, unit.min in all 16 languages.

Tests

  • TestKeyboardMarkup: the exact JSON sent to sendMessage.
  • TestKeyLabelsAreUnambiguous, TestKeyOfMatchesEveryLanguageInDMsOnly: matching in every language, never in groups or from bots.
  • TestStartSendsTheKeyboardInDMsOnly, TestLanguageChangeResendsTheKeyboard: a group never gets the keyboard, even from a forged language press.
  • TestMenuButtonSendsTheHome, TestTodaysResult, TestTodaysResultAfterTheDeadline.

gofmt -l ., go vet ./... and go test -race ./... pass. Not checked: the integration tests (no PostgreSQL needed for this change) and the keyboard on real iOS, Android and Desktop clients, which the issue's "Done when" asks for. maply-dev's fake Bot API ignores reply keyboards, so it will not show them.

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

amtiYo and others added 2 commits November 16, 2026 15:24
In a DM the menu button opens the Mini App, so the command list is hidden
and a new player has nothing to press after the first game. A persistent
reply keyboard keeps three buttons under the input field.

Play opens the day in the Mini App. Today's result reads the DM's zone:
before 20:00 it says whether the person has answered and how long until
the result (or that an earlier group reveal closed the day); from the
reveal it gives the score and the world rank, "so far" while western zones
are still answering, with a button into the result. Menu sends the home
panel.

The keyboard rides on its own short message, since a message has one
reply_markup and the panel's is inline. It is sent on /start in a DM and
again when the person's language changes. Button texts are matched in all
16 languages before any other text handling and count as nothing else.
Groups never get it, and there is no location button: a location in a DM
is the day's answer.

The telegram client gains a Keyboard type and SendKeyboard; tg needs no
release.

Refs #95

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@amtiYo
amtiYo merged commit acfb1b2 into dev Nov 16, 2026
8 checks passed
@amtiYo
amtiYo deleted the feat/dm-reply-keyboard branch November 19, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant